#include <iostream>
#include <fstream>
#include "function.h"

using namespace std;

int main () {
	std::ifstream input("input.txt");
	std::ofstream output("output.txt");

	int n;
	input >> n;

	for ( size_t i = 0; i != n; ++i ){
		string str;
		string op;
		double a = 0;
		double b = 0;
		double eps = 0;		
		double res = 0;
		input >> str >> op >> a >> b >> eps;

		Function f(str);
		if (op == "sol"){
			if (f.solve(a, b, eps, res)){
				output << res << endl;
			}else{
				output << "No solution" << endl;
			}
		}else{
			f.integrate(a, b, eps, res);
			output << res << endl;
		}

	}

	return 0;
}
